/*
 * @FilePath: /NLK/vite.prod.config.ts
 * 介绍:生产环境配置项
 */

import { defineConfig, loadEnv } from "vite";
import path from "path";
const mode = "production";
const env = loadEnv(mode, process.cwd(), "VITE_");

export default defineConfig({
  build: {
    minify: "terser",
    rollupOptions: {
      output: {
        chunkFileNames: "static/js/[name]-[hash].js",
        entryFileNames: "static/js/[name]-[hash].js",
        assetFileNames: "static/[ext]/[name]-[hash].[ext]",
      },
      manualChunks(id) {
        if (id.includes("node_modules")) {
          return "vendor";
        }
      },
    },
    outDir: path.join(__dirname, "dist/build"),
    terserOptions: {
      compress: {
        drop_console: true, // 生产环境移除console
        drop_debugger: true, // 生产环境移除debugger
      },
    },
  },
});
